#include "vl_props.h"
#include "vl_prop_file_writer.h"

using namespace VL;

VLPropFileWriter::VLPropFileWriter(const std::string& filePath): output(filePath, std::ios::out | std::ios::trunc) {
}

VLPropFileWriter::~VLPropFileWriter() {
	output.close();
}

void VLPropFileWriter::write(const uint8_t& byte) {
	if(output.fail()) {
		throw VLPropExcetion(VL_PROP_ERROR_WRITE, "write byte failed");
	}
	output.write((const char *) &byte, 1);
}

void VLPropFileWriter::writeBuf(const uint8_t* bytes, size_t length) {
	if(output.fail()) {
		throw VLPropExcetion(VL_PROP_ERROR_WRITE, "write buffer failed");
	}
	output.write((const char *) bytes, length);
}